﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage/List.Master" AutoEventWireup="true" CodeBehind="AuditTableBFGive_List.aspx.cs" Inherits="Honestysoft.Financing.WebUI.Module.Audit.AuditTableBFGive_List" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link rel="stylesheet" type="text/css" href="../../Styles/easyui.css" />
	<link rel="stylesheet" type="text/css" href="../../Styles/icon.css" />
	<script type="text/javascript" src="../../Scripts/jquery-1.6.min.js"></script>
	<script type="text/javascript" src="../../Scripts/jquery.easyui.min.js"></script>
	<script language="javascript" type="text/javascript">
//	    $(function () {
//	        var lastIndex;
//	        $('#tt').datagrid({
//	            loadMsg: "正在加载数据，请稍候……",
//	            url: 'GetAuditTableList.ashx?BatchNo=' + document.getElementById("<%=txtBatchNo.ClientID %>").value + '&ProjectSN=' + document.getElementById("<%=txtProjectSN.ClientID %>").value + '&ProjectName=' + document.getElementById("<%=txtProjectName.ClientID %>").value + '&ContractName=' + document.getElementById("<%=txtContractName.ClientID %>").value +
//                '&Code=' + document.getElementById("<%=txtCode.ClientID %>").value + '&IsBF=' + document.getElementById("<%=ddlBF.ClientID %>").options[document.getElementById("<%=ddlBF.ClientID %>").selectedIndex].value + '&IsGive=' + document.getElementById("<%=ddlGive.ClientID %>").options[document.getElementById("<%=ddlGive.ClientID %>").selectedIndex].value + '&randID=' + escape(new Date()),
//	            onBeforeLoad: function () {
//	                $(this).datagrid('rejectChanges');
//	            },
//	            onClickRow: function (rowIndex) {
//	                if (lastIndex != rowIndex) {
//	                    $('#tt').datagrid('endEdit', lastIndex);
//	                    $('#tt').datagrid('beginEdit', rowIndex);
//	                }
//	                lastIndex = rowIndex;
//	            }
//	        });
	    //	    });
	    function dataItem() {
	        var ID;
	        var GiveAmount;
	        var GiveDate;
	        var BFAmount;
	        var BFDate;
	    }
	    var DataItemArray = new Array();
        function setNewItem(id){
            var isExists=false;
            if (DataItemArray.length > 0) {
	            for (var i = 0; i < DataItemArray.length; i++) {
	                if (DataItemArray[i].ID == id) {
	                    isExists = true;
	                    break;
	                }
	            }
	        }
	        if (!isExists) {
	            var newItem = new dataItem();
	            newItem.ID = id;
	            newItem.GiveAmount = 0;
                newItem.GiveDate = "";
                newItem.BFAmount = 0;
                newItem.BFDate = "";
	            DataItemArray.push(newItem);
	        }
        }
	    function setGiveAmount(id, val) {
            setNewItem(id);
            for (var i = 0; i < DataItemArray.length; i++) {
                if (DataItemArray[i].ID == id) {
                    DataItemArray[i].GiveAmount = val;
                    break;
                }
            }
	    }
	    function setGiveDate(id, val) {
	        setNewItem(id);
	        for (var i = 0; i < DataItemArray.length; i++) {
	            if (DataItemArray[i].ID == id) {
	                DataItemArray[i].GiveDate = val;
	                break;
	            }
	        }
	    }
	    function setBFAmount(id, val) {
	        setNewItem(id);
	        for (var i = 0; i < DataItemArray.length; i++) {
	            if (DataItemArray[i].ID == id) {
	                DataItemArray[i].BFAmount = val;
	                break;
	            }
	        }
	    }
	    function setBFDate(id, val) {
	        setNewItem(id);
	        for (var i = 0; i < DataItemArray.length; i++) {
	            if (DataItemArray[i].ID == id) {
	                DataItemArray[i].BFDate = val;
	                break;
	            }
	        }
	    }
	    function setResult() {
	        if (DataItemArray.length == 0) {
	            alert("没有需要保存的数据！");
	            return false;
	        }
	        var res = "";
	        for (var i = 0; i < DataItemArray.length; i++) {
                //增加检测日期与金额的同时存在
	            if (DataItemArray[i].BFAmount != 0) {
	                if (DataItemArray[i].BFDate == null || DataItemArray[i].BFDate == "") {
	                    alert("有实拨金额时，必须选择实拨日期！");
	                    return false;
	                }
	            }
	            if (DataItemArray[i].BFDate != null && DataItemArray[i].BFDate != "") {
	                if (DataItemArray[i].BFAmount == 0) {
	                    alert("有实拨日期时，必须输入实拨金额！");
	                    return false;
	                }
	            }
	            if (DataItemArray[i].GiveAmount != 0) {
	                if (DataItemArray[i].GiveDate == null || DataItemArray[i].GiveDate == "") {
	                    alert("有放款金额时，必须选择放款日期！");
	                    return false;
	                }
	            }
	            if (DataItemArray[i].GiveDate != null && DataItemArray[i].GiveDate != "") {
	                if (DataItemArray[i].GiveAmount == 0) {
	                    alert("有放款日期时，必须输入放款金额！");
	                    return false;
	                }
	            }
                //end
	            if (res != "") {
	                res += ",";
	            }
	            res += DataItemArray[i].ID + "|" + DataItemArray[i].GiveAmount + "|" + DataItemArray[i].GiveDate + "|" + DataItemArray[i].BFAmount + "|" + DataItemArray[i].BFDate;
	        }
	        document.getElementById("<%=hidResult.ClientID %>").value = res;
	        return true;
	    }
	    function setValue(id, GAClientID, GDClientID, BAClientID, BDClientID) {
	        //alert("ID:" + id + ",GiveAmount:" + document.getElementById(GAClientID).value + ",GiveDate:" + document.getElementById(GDClientID).value + ",BFAmount:" + document.getElementById(BAClientID).value + ",BFDate:" + document.getElementById(BDClientID).value);
	        setGiveAmount(id, document.getElementById(GAClientID).value);
	        setGiveDate(id, document.getElementById(GDClientID).value);
	        setBFAmount(id, document.getElementById(BAClientID).value);
	        setBFDate(id, document.getElementById(BDClientID).value);
	    }
	</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="query_area">
        批次：<asp:TextBox ID="txtBatchNo" runat="server" Width="60px" cssClass="input2" onbeforepaste="numboxPaste();" onkeypress="isInt();" ></asp:TextBox>&nbsp;&nbsp;
		项目编号：<asp:TextBox ID="txtProjectSN" runat="server"  Width="60px"   cssClass="input2" MaxLength="200"></asp:TextBox>&nbsp;&nbsp;
        项目名称：<asp:TextBox ID="txtProjectName" runat="server"  cssClass="input2" MaxLength="200"></asp:TextBox>&nbsp;&nbsp;
		合同名称：<asp:TextBox ID="txtContractName" runat="server"  cssClass="input2" MaxLength="200"></asp:TextBox>&nbsp;&nbsp;
		审核作业表编号：<asp:TextBox ID="txtCode" runat="server"  cssClass="input2" MaxLength="200"></asp:TextBox>&nbsp;&nbsp;
        <br />
        放款状态：<asp:DropDownList runat="server" ID="ddlGive" cssClass="input2">
        <asp:ListItem Value="0">全部</asp:ListItem>
            <asp:ListItem Selected="True" Value="1">未放款</asp:ListItem>
            <asp:ListItem Value="2">已放款</asp:ListItem>
        </asp:DropDownList>
        拨付状态：<asp:DropDownList runat="server" ID="ddlBF" cssClass="input2">
            <asp:ListItem Value="0">全部</asp:ListItem>
            <asp:ListItem Selected="True" Value="1">未拨付</asp:ListItem>
            <asp:ListItem Value="2">已拨付</asp:ListItem>
        </asp:DropDownList>
        <asp:Button runat="server" ID="btnQuery" Text="查 找" CssClass="btn_normal" 
			onMouseOver="this.className='btn_active'" 
            onMouseOut="this.className='btn_normal'" onclick="btnQuery_Click" />&nbsp;&nbsp;
        <asp:Button runat="server" ID="btnSave" Text="保 存" CssClass="btn_normal" 
			onMouseOver="this.className='btn_active'" 
            onMouseOut="this.className='btn_normal'" onclick="btnSave_Click" OnClientClick="return setResult();" />
        <asp:HiddenField runat="server" ID="hidResult"  />
    </div>
    <table cellpadding="0" width="100%" cellspacing="0" border="1" class="t1" id="tGrid">
		<thead>  
            <th align="center" width="30px">批次</th>
            <th align="center" width="40px">项目编号</th>
            <th align="center">项目名称</th>
            <th align="center">合同名称</th>
            <th align="center">施工\监理单位</th>
            <th align="center"  width="110px">审核作业表编号</th>
            <th align="center" width="80px">请款金额</th>
            <th align="center" width="80px">初审金额</th>
            <th align="center" width="80px">放款金额</th>
            <th align="center" width="70px">放款日期</th>
            <th align="center" width="80px">实拨金额</th>
            <th align="center" width="70px">实拨日期</th>
      	</thead>           
		<asp:Repeater runat="server" ID="rptList" 
            onitemdatabound="rptList_ItemDataBound">
			<ItemTemplate>
				<tr>
					<td><%#  DataBinder.Eval(Container.DataItem,"BatchNo") %></td>
                    <td><%#  DataBinder.Eval(Container.DataItem, "ProjectSN")%></td>
					<td style="text-align:left"><%#  DataBinder.Eval(Container.DataItem,"ProjectName") %></td>
					<td style="text-align:left"><%#  DataBinder.Eval(Container.DataItem,"ContractName") %></td>
					<td style="text-align:left"><%#  DataBinder.Eval(Container.DataItem,"ContractorName") %></td>
                    <td><%#  DataBinder.Eval(Container.DataItem,"Code") %></td>
                    <td style="text-align:right"><%# string.Format("{0:N}",  DataBinder.Eval(Container.DataItem, "Amount_DocRec_S"))%></td>
                    <td style="text-align:right"><%# string.Format("{0:N}",   DataBinder.Eval(Container.DataItem, "Amount_S"))%></td>
                    <td><asp:TextBox runat="server" ID="txtGiveAmount" cssClass="input2" onbeforepaste="numboxPaste();" onkeypress="isDecimal();" Width="70px"></asp:TextBox></td>
                    <td><asp:TextBox runat="server" ID="txtGiveDate" cssClass="input2" onfocus="setday(this);" Width="60px"></asp:TextBox></td>
                    <td><asp:TextBox runat="server" ID="txtBFAmount" cssClass="input2" onbeforepaste="numboxPaste();" onkeypress="isDecimal();" Width="70px"></asp:TextBox></td>
                    <td><asp:TextBox runat="server" ID="txtBFDate" cssClass="input2" onfocus="setday(this);" Width="60px"></asp:TextBox></td>
				</tr>  
			</ItemTemplate>
		</asp:Repeater>
    </table>
    <div class="paging_area">
     <frameworkwebcontrols:aspnetpager id="AspNetPager1" runat="server"
                    alwaysshow="true" firstpagetext="首页" lastpagetext="尾页" nextpagetext="下一页" pageindexboxtype="DropDownList"
                    prevpagetext="上一页" showpageindex="true" showcustominfosection="Right" submitbuttontext="Go"
                    textafterpageindexbox="页" textbeforepageindexbox="转到" currentpagebuttonposition="End"
                    layouttype="Div" custominfotextalign="Right" custominfohtml="共%RecordCount%条记录。第%CurrentPageIndex%页，共%PageCount%页，每页%PageSize%条"
                    direction="LeftToRight" onpagechanged="AspNetPager1_PageChanged">
                </frameworkwebcontrols:aspnetpager>  
    </div>
</asp:Content>
